package cn.dw.mm.controller;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import cn.dw.mm.domain.Asset;
import cn.dw.mm.service.AssetService;

@Controller
@RequestMapping("/asset")
public class AssetController {
	
	@Autowired
	private AssetService assetService;
	
	@RequestMapping("/add")
	@ResponseBody
	public String add(Asset asset) {
		//自动生成编码
		asset.setId(UUID.randomUUID().toString());
		assetService.insert(asset);
		JSONObject json = new JSONObject();
		json.put("result", "success");
		return json.toJSONString();
	}
	
	
	@RequestMapping("/query")
	@ResponseBody
	public List<Asset> query(Asset asset) {
		return assetService.selectAll(asset);
		
	}
	
	@RequestMapping("/page")
	public String page() {
		return "asset/assetlist";
	}
}
